package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.goodsparameters.GoodsParametersBO;
import com.micro.modual.model.dto.goodsparameters.GoodsParametersDetailDTO;
import com.micro.modual.model.dto.goodsparameters.GoodsParametersExistBO;
import com.micro.modual.model.dto.goodsparameters.GoodsParametersListDTO;
import com.micro.modual.service.GoodsParametersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.Map;

/**
 * <h1>商品参数表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "商品参数管理",tags = "商品参数管理")
@RestController
@RequestMapping(value = "goodsParameters")
public class GoodsParametersController {

    @Autowired
    private GoodsParametersService goodsParametersService;

    /**
     * <h2>查找商品参数表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<GoodsParametersListDTO> {@link GoodsParametersListDTO}s  商品参数表 列表返回对象
     */
    @ApiOperation(value = "查询商品参数表列表" ,notes = "查询商品参数表列表")
    @GetMapping(value = "/findGoodsParametersList")
    public RespJsonPageData<GoodsParametersListDTO> findGoodsParametersList(@RequestParam  Map<String,Object> params){
        return goodsParametersService.findList(params,GoodsParametersListDTO.class);
    }

    /**
     * <h2>根据主键编号查看商品参数表详情</h2>
     * @param id  商品参数表 主键编号
     * @return {@link GoodsParametersDetailDTO}  商品参数表 详情
     */
    @ApiOperation(value = "查询商品参数表详情",notes = "根据主键编号，查询商品参数表详情")
    @GetMapping(value = "/findGoodsParametersDetail/{id}")
    public RespJsonData<GoodsParametersDetailDTO> findGoodsParametersDetail(@PathVariable("id") Long id){
        return goodsParametersService.findDetail(id,GoodsParametersDetailDTO.class);
    }

    /**
     * <h2>新增商品参数表详情</h2>
     * @param goodsParametersBO {@link GoodsParametersBO} 商品参数表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增商品参数表",notes = "新增商品参数表")
    @PostMapping(value = "/addGoodsParameters")
    public RespJson addGoodsParameters(@RequestBody GoodsParametersBO goodsParametersBO){
        return goodsParametersService.addGoodsParameters(goodsParametersBO);
    }

    /**
     * <h2>修改商品参数表详情</h2>
     * @param goodsParametersBO  {@link GoodsParametersBO} 商品参数表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改商品参数表",notes = "修改商品参数表")
    @PostMapping(value = "/editGoodsParameters")
    public RespJson editGoodsParameters(@RequestBody GoodsParametersBO goodsParametersBO){
        return goodsParametersService.editGoodsParameters(goodsParametersBO);
    }

    /**
     * <h2>根据主键编号删除商品参数表信息</h2>
     * @param id  商品参数表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除商品参数表",notes = "根据地址ID，删除商品参数表")
    @PostMapping(value = "/deleteGoodsParameters/{id}")
    public RespJson deleteGoodsParameters(@PathVariable("id") Long id){
        return goodsParametersService.deleteGoodsParameters(id);
    }

    /**
     * <h2>﻿校验参数名是否存在</h2>
     * @param goodsParametersExistBO {@link GoodsParametersExistBO} 参数请求对象
     * @return
     */
    @ApiOperation(value = "校验参数名是否存在",notes = "校验参数名是否存在")
    @PostMapping(value = "/validataParamsNameExist")
    public RespJson validataParamsNameExist(@RequestBody GoodsParametersExistBO goodsParametersExistBO){
        return goodsParametersService.validataParamsNameExist(goodsParametersExistBO);
    }
}

